package com.fenqing.leetcode.code.t0_200.t0_100;

import cn.hutool.core.util.ArrayUtil;
import com.fenqing.annotations.Execute;
import com.fenqing.core.Topic;

import java.util.Arrays;

/**
 * @author fenqing
 */
public class Topic026 extends Topic {

    /**
     * 构造器
     *
     * @param input 输入
     */
    public Topic026(String input) {
        super(input);
    }

    @Execute
    public int removeDuplicates(int[] nums) {
        int index = 0, index2 = 1;
        while (index2 < nums.length) {
            if (nums[index] != nums[index2]) {
                nums[index + 1] = nums[index2];
                index++;
            }
            index2++;
        }
        return index + 1;
    }


    public static void main(String[] args) {
        Topic026 topic26 = new Topic026("[1,1,2]");
        Integer run = topic26.run();
        int[] object1 = topic26.getObject(0);
        System.out.println(Arrays.toString(ArrayUtil.sub(object1, 0, run)));
        System.out.println(run);
    }

}
